package com.shandao.shangxiu.popup;


import android.content.Context;
import android.graphics.drawable.ColorDrawable;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.widget.LinearLayout.LayoutParams;
import android.widget.ListView;
import android.widget.PopupWindow;

import com.shandao.shangxiu.R;
import com.shandao.shangxiu.interf.PopupMenuClickListener;


/**
 * 显示选择图片的popupwindow
 * @author king
 */
public class MyPopupPickPhoto extends PopupWindow {
	private Context context;
	private ListView listView;
	private PopupMenuClickListener listener;

	public MyPopupPickPhoto(Context context){
		this.context=context;
		LayoutInflater inflater = (LayoutInflater) context
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		View conentView = inflater.inflate(R.layout.popup_pick_photo, null);
		iniView(conentView);
		this.setContentView(conentView);
		this.setWidth(LayoutParams.MATCH_PARENT);
		this.setHeight(LayoutParams.MATCH_PARENT);
		this.setFocusable(true);
		this.setTouchable(true);
		this.setOutsideTouchable(true);
		// 刷新状态
		this.update();
		// 实例化一个ColorDrawable颜色为半透明
		ColorDrawable dw = new ColorDrawable(0000000000);
		// 点back键和其他地方使其消失,设置了这个才能触发OnDismisslistener ，设置其他控件变化等操作
		this.setBackgroundDrawable(dw);
	}

	private void iniView(View conentView) {

		conentView.findViewById(R.id.tv_graph).setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				listener.onPopueMenuItemClick(v.getId(),"");
			}
		});
		conentView.findViewById(R.id.tv_pick).setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				listener.onPopueMenuItemClick(v.getId(),"");
			}
		});
		conentView.findViewById(R.id.tv_cancel).setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				listener.onPopueMenuItemClick(v.getId(),"");
			}
		});


	}

	public void setListener(PopupMenuClickListener listener){
		this.listener=listener;
	}


}
